<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<script type="text/javascript">
function movePage(pageNo) {
	//window.location = '?pageNo=' + pageNo + param();
	$.get("myPositionList.do?pageNo=" + pageNo + param() + "&" + Math.random(),
			function(data) {
				$("#main").html(data);
			});
}
function param() {
	var param = "";
	if ($("#name").val() != "")
		param += '&name=' + $("#name").val();
	if ($("#region").val() != "")
		param += '&region=' + $("#region").val();
	if ($("#detail").val() != "")
		param += '&detail=' + $("#detail").val();
	return param;
}
function del(id) {
if(confirm('确定删除？'))
	$.get("delPosition.do?"+Math.random(),{id:id}, function(data){
	var o = jQuery.parseJSON(data);
					if(o.success){
						movePage(${param.pageNo});
						alert('操作成功！');
					}
					else
						alert('操作失败！'+o.err);
	});
}
$(document).ready(function() {
		$.get("getSelect.do",{type:'1',code:null,index:'${param.region}'}, function(data){$("select#region").append(data);});
		$.get("getSelect.do",{type:'zw',index:'${param.name}',code:null}, function(data){$("select#name").append(data);});
		$("#search").button().click(function() {
			movePage(1);
		});
		$("#add").button().click(function() {
			$.get("positionForm.do?&"+Math.random(), function(data) {
				$("#main").html(data);
			});
		});
});
	function edit(id){
		$.get("positionForm.do?&id="+id+"&"+Math.random(), function(data) {
				$("#main").html(data);
			});
	}
	function del(id) {
		$.get("deletePosition.do?id="+id,function(data){
			var o = jQuery.parseJSON(data);
					if(o.success){
						movePage(${param.pageNo});
						alert('操作成功！');
					}
					else
						alert('操作失败！'+o.err);
			
		});
	}
</script>
<table class="list" cellpadding="0" width="100%" cellspacing="1">
	<thead>
		<tr>
			<td colspan="8" class="search">
				<select id="name">
					<option value="">
						选择职位
					</option>
				</select>
				<select id="region">
					<option value="">
						选择区域
					</option>
				</select>
				<label>
					内容：
				</label>
				<input type="text" id="detail" value="${param.detail }" />
				<button id="search">
					查询
				</button>
				<button id="add">
					发布
				</button>
			</td>
		</tr>
		<tr>
			<td>
				职位名称
			</td>
			<td>
				区域
			</td>
			<td>
				性别
			</td>
			<td>
				工资
			</td>
			<td>
				是否兼职
			</td>
			<td>
				人数
			</td>
			<td>
				有效期
			</td>
			<td>
				操作
			</td>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="e" items="${o.dataList}" varStatus="s">
			<tr>
				<td>
					<a href="viewPosition.do?id=${e.id }" target="_blank">${e.name
						}</a>
				</td>
				<td>
					${e.region }
				</td>
				<td align="center">
					${e.sex }
				</td>
				<td align="center">
					${e.wages }
				</td>
				<td align="center">
					${e.workType }
				</td>
				<td align="center">
					${e.persons }
				</td>
				<td align="center">
					${e.days }
				</td>
				<td align="center">
					<a href="javascript:edit(${e.id})"><img src="lib/images/write.png"/></a>
					<a href="javascript:if(confirm('确定删除？'))del(${e.id});"><img src="lib/images/close.gif"/></a>
				</td>
			</tr>
		</c:forEach>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="8">
				${o.pageNav }
			</td>
		</tr>
	</tfoot>
</table>